Processors are used extensively today in almost every electronic application. The processor controls the execution of program instructions, arithmetic functions, and access to memory and peripherals. In the simplest form, the processor executes program instructions by performing one or more arithmetic functions on data stored in memory. The arithmetic functions performed by the processor may vary depending upon the particular application. One type of arithmetic function that is commonly performed by the processor is a shifting or rotating operation. The shifting or rotating operation may be performed by a rotator and associated logic. A rotator is an arrangement of multiplexer elements that have their inputs and outputs connected together in such a way that the data is shifted down the line in response to a program instruction calling for a shift operation.
The specific shifting operation called for by the program instruction may vary. For example, the program instruction may require a logical shift wherein the data is moved a discrete number of bit positions with the excess bits being discarded and the result being padded with zeros. An arithmetic shift is similar to a logical shift except the sign bit is extended to the left in a right shift operation and zeros are added to the lower-order bit positions in a left shift operation.
A rotator may also be used to execute program instructions calling for a rotate operation. A rotate operation is similar to the shift operation, except that the rotate operation is circular. When a rotate instruction is implemented, the bits that are shifted out one end of the rotator are returned on the other end. Like shift instructions, rotate instructions can be to the left or right.
Because program instructions for shift and rotate operations can be bi-directional, some processors incorporate a discrete left rotator and a right rotator. However, incorporating both may consume additional power and require more area or space. Accordingly, there is a need in the art for a processor based rotator that can execute shift and rotate instructions in both the left and right directions. The processor based rotator should be configured to minimize the latencies of the shifting and rotating operations.